package cc.jq1024.middleware.encrypt.domain.entity;

import java.io.Serializable;

/**
 * @author li--jiaqiang
 */
public class Response<T> implements Serializable {

    private String code;
    private String info;
    private T data;

    public Response() {

    }

    private Response(Builder<T> builder) {
        this.code = builder.code;
        this.info = builder.info;
        this.data = builder.data;
    }

    // Builder class
    public static class Builder<T> {
        private String code;
        private String info;
        private T data;

        public Builder() {
        }

        public Builder<T> code(String code) {
            this.code = code;
            return this;
        }

        public Builder<T> info(String info) {
            this.info = info;
            return this;
        }

        public Builder<T> data(T data) {
            this.data = data;
            return this;
        }

        public Response<T> build() {
            return new Response<>(this);
        }
    }

    public Response(String code, String info, T data) {
        this.code = code;
        this.info = info;
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    // Static method to create a Builder
    public static <T> Builder<T> builder() {
        return new Builder<>();
    }
}